<%-- 
    Document   : Summit
    Created on : 3/04/2011, 10:52:08 PM
    Author     : Jhon
--%>

<%@page import="HTML.HtmlContent"%>
<%@page import="HTML.HtmlSideBar"%>
<%@page import="HTML.HtmlBody"%>
<%@page import="vo.VOUser"%>
<%@page import="java.util.Date"%>
<%@page import="control.Controller"%>
<%@page import="vo.VOSubmission"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%

    String pname =  request.getParameter("pname");
    String cname =  request.getParameter("cname");
    String compilator=  request.getParameter("compilator");
    String code= request.getParameter("textarea");
    if(pname ==null || pname=="" || code==null || code ==""){
    response.sendRedirect("SubirSolucion.jsp");
    return;
    }
    VOUser a = (VOUser) session.getAttribute("USER");
    Controller con = Controller.getInstance();
    VOSubmission s = new VOSubmission();
    s.setCode(code);
    s.setDate(new Date());
    s.setContestCode(cname);
    s.setProblemCode(pname);
    s.setLanguage(compilator);
    s.setUserHandle(a.getHandle());
    try{
    con.submit(s);
    }catch(Exception e){
        session.setAttribute("ERROR", e.getMessage());
        response.sendRedirect("../Error/Error.jsp");
        return;
    
    }
    response.sendRedirect("./ListSubmit.jsp");
    %>



